package com.yunwaikeji.gy_tool_library.mvvm.view.admin;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.yunwaikeji.gy_tool_library.R;
import com.yunwaikeji.gy_tool_library.view.GYLinearLayout;

public class GYViewAdminLayout extends GYLinearLayout {
    public GYViewAdminLayout(Context context) {
        super(context);
    }

    public GYViewAdminLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView(attrs);
    }

    public GYViewAdminLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(attrs);
    }

    public GYViewAdminLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        initView(attrs);
    }

    private int layoutLocation = 0;

    @Override
    public void initView(AttributeSet attributeSet) {
        super.initView(attributeSet);
        if (getOrientation() != LinearLayout.VERTICAL && getOrientation() != LinearLayout.HORIZONTAL) {
            setOrientation(LinearLayout.VERTICAL);
        }
        if (attributeSet != null) {
            TypedArray typedArray = getContext().obtainStyledAttributes(attributeSet, R.styleable.GYBaseViewLayout);
            layoutLocation = typedArray.getInteger(R.styleable.GYBaseViewLayout_layoutLocation, layoutLocation);
            typedArray.recycle();
        }
    }

    public int getLayoutLocation() {
        return layoutLocation;
    }
}
